package java_thinking.unit_19._19_1_6;

import java_thinking.unit_15._15_3.Generator;

import java.util.Random;

/**
 * @Desc:
 * @author: cww
 * @DateTime: 2019/5/22 19:56
 */
enum CartoonCharacter implements Generator<CartoonCharacter> {
    SLAPPY, SPANKY, PUNCHY, SILLY, BOUNCY, NUTTY, BOB;
    private Random rand = new Random(47);
    public CartoonCharacter next() {
        return values()[rand.nextInt(values().length)];
    }
}
public class EnumImplementation {
    public static <T> void printNext(Generator<T> rg) {
        System.out.println(rg.next() + " ");
    }

    public static void main(String[] args) {
        CartoonCharacter cc = CartoonCharacter.BOB;
        for (int i = 0; i < 10; i++) {
            //必须要有一个enum实例才能调用其上的方法
            printNext(cc);
        }
    }
}
